import { defineStore } from 'pinia'
import { hotWord, getCate, homeList } from '../../network/home'
export const useHome = defineStore('home', {
  state: () => ({
    hotCitys: {}, cateGory: {}, currentPage: 1,
    homelist: []
  }),
  actions: {
    async getHotWord() {
      let res = await hotWord()
      this.hotCitys = res.data.data
    },
    async getCateGory() {
      let res = await getCate();
      this.cateGory = res.data.data
    },
    async getHomeList() {
      let res = await homeList({
        page: this.currentPage
      });
      // this.homelist = res.data.data;
      this.homelist = [...this.homelist, ...res.data.data]
      this.currentPage++
    }
  }
})